package com.zhicheng.controller;

import com.zhicheng.pojo.result.Result;
import com.zhicheng.pojo.vo.BannerVO;
import com.zhicheng.pojo.vo.CategoryVO;
import com.zhicheng.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/home")
@Api(tags = "主页相关接口")
public class HomeController {

    @Autowired
    private HomeService homeService;

    /**
     * 获取一级分类列表
     * @return
     */
    @GetMapping("/category/head")
    @ApiOperation("获取一级分类列表")
    public Result<List<CategoryVO>> getCategoryHead(){
        List<CategoryVO> categoryVO = homeService.getCategoryHead();
        return Result.success(categoryVO);
    }

    /**
     * 获取轮播图数据
     * @return
     */
    @GetMapping("/banner")
    @ApiOperation("获取全部轮播图数据")
    public Result<List<BannerVO>> getBannerAll(){
        List<BannerVO> banner =  homeService.selectBannerAll();
        return Result.success(banner);
    }

    /**
     * 获取全部商品数据
     * @return
     */
    @GetMapping("/goods")
    @ApiOperation("获取全部商品数据")
    public Result<List<CategoryVO>> getGoods(){
        List<CategoryVO> goods = homeService.getGoods();
        return Result.success(goods);
    }


}
